<?php
	//Check to see if there is a valid session 
	$SessionInfo = $SSO->isValidSession("index.php?action=login", $SSO->getSessionInformation());	
	
	//Check to see if the user has rights to be on LivingWeb
	$PageRights = array('ADMIN', 'USER');
	$UserRoles = $Security->ValidateUser($SessionInfo['username'], $AppID, $PageRights, 1);
	
	//Grab the user info
	$UserInfo = $User->GetUserInfo($SessionInfo['username']);	

	//Check to see if there is a valid session 
	$SessionInfo = $SSO->isValidSession("index.php?action=login", $SSO->getSessionInformation());	
	if(!isset($_GET['PID']) || $_GET['PID'] == "")
	{
		print '<span class="LivingWebText">No Page Id was provided!</span><br><a href="index.php?action=main" class="LivingWebLink">Back to the Main Page</a>';
		exit();	
	}

	if(isset($_POST['btnSubmit']) && $_POST['btnSubmit'] == 'Update')
	{ 
		global $DB;
		//$DB->query("UPDATE pages p LEFT JOIN page_content pc ON p.PageID = pc.PageID WHERE p.PageID = '" . $_GET['PID'] . "'");
	}
	
	if(isset($_GET['PID']))
	{
		global $DB;
		$DB->query("SELECT * FROM pages p LEFT JOIN page_content pc ON p.PageID = pc.PageID WHERE p.PageID = '" . $_GET['PID'] . "'");
		$row = $DB->fetch_row();

		$page_title = $row['PageTitle']; 
		$content_value = $row['Content'];
	}
	else
	{
		$page_title = "";
		$content_value = "";
	}
?>
<form action="index.php?action=edit" method="post" name="frmEditPID">
	<span class="T1">Page Title</span>&nbsp;<input name="txtPageTitle" type="text" value="<?php	print $page_title; ?>" class="T1" size="50"><br><br>

	<?php
		include_once("CMS/fckeditor.php");
		$oFCKeditor = new FCKeditor('txtFCKeditor');
		$oFCKeditor->BasePath	= "/LivingWeb/CMS/";
		$oFCKeditor->Height		= 500;
		$oFCKeditor->Value		= $content_value;
		$oFCKeditor->Create();
	?>
	
	<input name="txtPID" type="hidden" value="<?php 
	if(isset($_GET['PID']))
	{
		print $_GET['PID'];
	}
	else
	{
		global $PageServer;
		print $PageServer->GetNewPID();
	}
	?>">
	<input name="btnSubmit" type="submit" class="B" value="Update">	
</form>